package featuremodel.constraint;

import java.util.Vector;

import featuremodel.FeatureGroup;
import featuremodel.FeatureModelDef;
import featuremodel.predication.CompositeAllFalseOne;
import featuremodel.predication.CompositeAllTrue;
import featuremodel.predication.CompositeMultiFalseNone;
import featuremodel.predication.CompositeMultiTrue;
import featuremodel.predication.CompositeNoneFalseOne;
import featuremodel.predication.CompositeNoneTrue;
import featuremodel.predication.CompositeSingleFalseNone;
import featuremodel.predication.CompositeSingleTrue;

import skyblue.Constraint;
import skyblue.Method;
import skyblue.Strength;

public class CompositeConstraint extends Constraint {

	protected Vector<Method> tempMethods;

	public CompositeConstraint(Strength strength) {
		super(strength);
		tempMethods = new Vector<Method>();

	}

	public void setGroupPredicTrue(FeatureGroup featureGroup, String groupType) {

		tempMethods.clear();

		if (groupType.equals(FeatureModelDef.PREDICATE_ALL)) {
			tempMethods.add(new CompositeAllTrue(featureGroup));
		} else if (groupType.equals(FeatureModelDef.PREDICATE_SINGLE)) {
			for (int i = 0; i < featureGroup.getVariables().size(); i++) {
				tempMethods.add(new CompositeSingleTrue(featureGroup
						.getVariables().get(i), featureGroup));
			}
		} else if (groupType.equals(FeatureModelDef.PREDICATE_MULTI)) {
			for (int i = 0; i < featureGroup.getVariables().size(); i++) {
				tempMethods.add(new CompositeMultiTrue(featureGroup
						.getVariables().get(i)));
			}
		} else if (groupType.equals(FeatureModelDef.PREDICATE_NONE)) {
			tempMethods.add(new CompositeNoneTrue(featureGroup));

		}

	}

	public void setGroupPredicFalse(FeatureGroup featureGroup, String groupType) {

		tempMethods.clear();

		if (groupType.equals(FeatureModelDef.PREDICATE_ALL)) {
			for (int i = 0; i < featureGroup.getVariables().size(); i++) {
				tempMethods.add(new CompositeAllFalseOne(featureGroup
						.getVariables().get(i)));
			}

		} else if (groupType.equals(FeatureModelDef.PREDICATE_SINGLE)) {
			tempMethods.add(new CompositeSingleFalseNone(featureGroup));
			// at least two of the features are bind
			// TODO find out the two constraint
			// new CompositeSingleFalseTwo(featureGroup);
		} else if (groupType.equals(FeatureModelDef.PREDICATE_MULTI)) {

			tempMethods.add(new CompositeMultiFalseNone(featureGroup));

		} else if (groupType.equals(FeatureModelDef.PREDICATE_NONE)) {
			// at least one of the feature is bind
			for (int i = 0; i < featureGroup.getVariables().size(); i++) {
				tempMethods.add(new CompositeNoneFalseOne(featureGroup
						.getVariables().get(i)));
			}
		}

	}

	public Vector<Method> getTempMethods() {
		return tempMethods;
	}

	public void setTempMethods(Vector<Method> tempMethods) {
		this.tempMethods = tempMethods;
	}

}
